Skip to main content

Create Conversion

Execute a foreign exchange conversion based on the FIRM quote obtained from Get FX Quote. quote_id is mandatory — conversions without a quote are not supported.

Workflow

Idempotency Mechanism

request_id is the idempotency key. If Merchant resends a request with the same request_id (due to timeout, retry), the system does not create a new order but returns the result of the original order.

Handling timeout:

  • Timeout with unclear result → (1) retry with same request_id, or (2) query via Get Conversion Detail
  • Do not change request_id when retrying for the same order

Quote Binding Constraints

  • Each quote_id executes successfully only once → resending already-used quote (with different request_id) → code 426
  • Quote past expires_at → code 425, request a new quote
  • Quote must belong to the same merchant_code that obtained it; mismatch → code 425

Endpoint

  • URL: /api/v1/fx/convert
  • Method: POST

Request

ParameterData TypeRequiredDescription
request_idstring(50)YesUnique code identifying the request, serving as idempotency key. See section 3 Introduction
request_timestring(19)YesSee section 3 Introduction
merchant_codestring(20)YesSee section 3 Introduction
quote_idstring(50)YesFIRM quote code obtained from Get FX Quote, still within expiry time (expires_at)
from_currencystring(3)YesSource currency, must match exactly with the quote
from_amountdecimal(18,2)YesSource amount to convert, must match exactly with from_amount in the quote

Amount Cross-Check Mechanism

from_currency and from_amount are explicit confirmation fields, must match exactly with values in the quote.

Mismatch → code 428, order not executed. Merchant wants to convert a different amount → request a new FIRM quote.

Example Request

{
"request_id": "MERCHANT1234BK202606050002",
"request_time": "2026-06-05 10:15:45",
"merchant_code": "MERCHANT1234",
"quote_id": "FXQ0605A7K2M9XD41",
"from_currency": "USD",
"from_amount": 10000.00
}

Response

ParameterData TypeRequiredDescription
response_codeint(4)YesResult code. 200 = success (check status in data), other codes = error
response_messagestring(200)YesDescription of the result code
merchant_codestring(20)YesMerchant code
dataObjectYesConversion order details (see table below)

data Structure

ParameterData TypeDescription
conversion_idstring(50)Conversion order code generated by Baokim, used for querying and reconciliation
origin_request_idstring(50)request_id of the original order (equals the request_id sent; useful when response comes from idempotency mechanism)
statusstring(20)Order status: PROCESSING (processing), SUCCESS (success), FAILED (failed, no balance movement)
quote_idstring(50)Quote code executed
trade_typestring(4)Transaction type (SELL/BUY)
currency_pairstring(10)Normalized currency pair (e.g., USD/VND)
ratedecimal(18,4)Exchange rate executed (same as rate in quote)
from_currencystring(3)Source currency
from_amountdecimal(18,2)Source amount deducted
to_currencystring(3)Destination currency
to_amountdecimal(18,2)Destination amount credited
created_atstring(19)Order creation time (GMT+7), format YYYY-MM-DD HH:MM:SS
completed_atstring(19)Completion time. Null when status = PROCESSING.

Example Response

{
"response_code": 200,
"response_message": "Success",
"merchant_code": "MERCHANT1234",
"data": {
"conversion_id": "FXC202606051015450001",
"origin_request_id": "MERCHANT1234BK202606050002",
"status": "SUCCESS",
"quote_id": "FXQ0605A7K2M9XD41",
"trade_type": "SELL",
"currency_pair": "USD/VND",
"rate": 26450.0000,
"from_currency": "USD",
"from_amount": 10000.00,
"to_currency": "VND",
"to_amount": 264500000,
"created_at": "2026-06-05 10:15:45",
"completed_at": "2026-06-05 10:15:46"
}
}

Notes

Timeout or connection loss when calling this API does not mean the order failed. Merchant must handle via the idempotency mechanism above, not assume FAILED status. Use Get Conversion Detail to determine the final result.

Error Codes

Response CodeResponse MessageDescription
200SuccessCheck status in data for order result
101System errorUnexpected error on Baokim's side
110Invalid merchant codemerchant_code is undefined
120Invalid SignatureSignature header is invalid
422Validation errorRequest field is missing or invalid
425Quote not found, expired, or not owned by merchantQuote past expires_at, not found, or not belonging to this merchant
426Quote already usedThis quote_id was already executed successfully (single-use)
427Insufficient balanceNot enough source currency to execute conversion
428Amount/currency mismatch with quotefrom_currency or from_amount does not match quote
429Too many requestsExceeded rate limit for Merchant